# 阶段 1：编译（使用 Go 1.22.2）
FROM m.daocloud.io/docker.io/golang:1.22.2-alpine AS builder
WORKDIR /app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/redis_calculator

# 阶段 2：运行镜像
FROM alpine:3.19
WORKDIR /app
COPY --from=builder /app/redis_calculator /app/
CMD ["/app/redis_calculator"]